/* Copyright (c) 2004-2008, Andriy Nikolov
 * All rights reserved.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package org.processmining.analysis.email;

import javax.swing.table.*;
import org.processmining.email.*;

/**
 * <p> A service class representing a table model for the process instances list
 * table. Used by EMailProcessLogAnalysis plugin
 *
 * @author Andriy Nikolov
 * @version 1.0
 */
public class EMailProcessInstancesListTableModel
    extends AbstractTableModel {
  ProcessLog log;

  public EMailProcessInstancesListTableModel() {
    try {
      jbInit();
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  public EMailProcessInstancesListTableModel(ProcessLog log) {
    this.log = log;
  }

  /**
   * Returns the number of columns in the model.
   *
   * @return the number of columns in the model
   * @todo Implement this javax.swing.table.TableModel method
   */
  public int getColumnCount() {
    return 1;
  }

  /**
   * Returns the number of rows in the model.
   *
   * @return the number of rows in the model
   * @todo Implement this javax.swing.table.TableModel method
   */
  public int getRowCount() {
    return log.getOrderedCaseList().size();
  }

  /**
   * Returns the value for the cell at <code>columnIndex</code> and
   * <code>rowIndex</code>.
   *
   * @param rowIndex the row whose value is to be queried
   * @param columnIndex the column whose value is to be queried
   * @return the value Object at the specified cell
   * @todo Implement this javax.swing.table.TableModel method
   */
  public Object getValueAt(int rowIndex, int columnIndex) {
    ProcessCase pi = (ProcessCase)log.getOrderedCaseList().get(rowIndex);
    if(columnIndex!=0)
      return null;
    //return new Integer(rowIndex).toString();
    return pi.getDescription();
  }

  public String getColumnName(int col) {
    if(col==0)
      return "Process instances";
    return null;
  }

    public Class getColumnClass(int c) {
      return new String().getClass();
    }

    public boolean isCellEditable(int row, int col) {
      return false;
  }

  private void jbInit() throws Exception {
  }
}
